#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define P(k) p[k-1]
int printarray(int *p)
{
	int i=0;
	while(p[i]!=0)
	{
		printf("%d ",p[i]);
		i++;
	}
	printf("\n");
	return 0;
}

int subproblem(int *p,int s,int n,int k)
{
	int i=0;
	if(k<1)
	{
		printarray(p);
		return 1;
	}
	if(s<=n)
	{
		P(k)=s;
		i=subproblem(p,s+1,n,k-1);
		i+=subproblem(p,s+1,n,k);
	}
	return i;
}
	

int nckprint(int n,int k)
{
	int i,j;
	int *p;
	p=(int *)malloc((n+1)*sizeof(int));
	P(k+1)=0;
	i=subproblem(p,1,n,k);
	free(p);
	return i;
}


int main()
{
	int i,j;
	int n,k;
	scanf("%d %d",&n,&k);
	printf("total no combinations is %d\n",nckprint(n,k));
	return 0;
}
